﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Pahan.McuFusion.UI.Interfaces;

namespace Pahan.McuFusion.UI.Views
{
    public partial class RunningScriptView : Form, IRunningScriptView
    {
        public RunningScriptView()
        {
            InitializeComponent();
        }

        #region Implementation of IRunningScriptView

        /// <summary>
        /// Clears the displayed messages.
        /// </summary>
        public void Clear()
        {
            txtOut.Clear();
        }

        /// <summary>
        /// Displays the error.
        /// </summary>
        public void WriteError(string message)
        {
            WriteMessage(message, Color.Red);
        }

        /// <summary>
        /// Dispays the warning.
        /// </summary>
        public void WriteWarning(string message)
        {
            WriteMessage(message, Color.Yellow);
        }

        /// <summary>
        /// Displays the information message.
        /// </summary>
        public void WriteInfo(string message)
        {
            WriteMessage(message, Color.Black);
        }

        /// <summary>
        /// Displays the system message.
        /// </summary>
        public void WriteSystem(string message)
        {
            WriteMessage(message, Color.Azure);
        }

        #endregion

        private void WriteMessage(String message, Color color)
        {
            txtOut.SelectionStart = txtOut.TextLength;
            txtOut.SelectionColor = color;
            txtOut.AppendText(message);
            txtOut.AppendText(Environment.NewLine);
        }
    }
}
